
package com.x52im.rbchat.logic.chat_root.model;

import com.google.gson.Gson;

/**
 * 实时音视频聊天记录信息的元数据.
 *
 * @author JackJiang
 * @since 10.0
 */
public class VoipRecordMeta {

    /** 实时语音聊天 */
    public final static int VOIP_TYPE_VOICE = 0;
    /** 实时视频聊天 */
    public final static int VOIP_TYPE_VIDEO = 1;

    /** 记录类型：取消了呼叫 */
    public final static int RECORD_TYPE_REQUEST_CANCEL = 0;
    /** 记录类型：拒绝了呼叫 */
    public final static int RECORD_TYPE_REQUEST_REJECT = 1;
    /** 记录类型：呼叫超时 */
    public final static int RECORD_TYPE_CALLING_TIMEOUT = 2;
    /** 记录类型：通话记录（通话时长） */
    public final static int RECORD_TYPE_CHATTING_DURATION = 3;

    /** 聊天类型 */
    private int voipType = VOIP_TYPE_VIDEO;

    /** 记录类型 */
    private int recordType = RECORD_TYPE_CHATTING_DURATION;

    /** 通话时长（单位：秒），本字段仅在 recordType 为{@link VOIP_TYPE_CHATTING_DURATION} 时有效 */
    private int duration = 0;

    public VoipRecordMeta(int voipType, int recordType) {
        this(voipType, recordType, 0);
    }

    public VoipRecordMeta(int voipType, int recordType, int duration) {
        this.voipType = voipType;
        this.recordType = recordType;
        this.duration = duration;
    }

    public int getVoipType() {
        return voipType;
    }

    public void setVoipType(int voipType) {
        this.voipType = voipType;
    }

    public int getRecordType() {
        return recordType;
    }

    public void setRecordType(int recordType) {
        this.recordType = recordType;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public static VoipRecordMeta fromJSON(String jsonOfLocationMeta) {
        return new Gson().fromJson(jsonOfLocationMeta, VoipRecordMeta.class);
    }
}
